<div class="account-main-section main-height">
    <div class="channel-content text-white">
        <h3 class="channel-content-header text-uppercase text-white">{{language=='en'?'Modify Password':''}}{{language=='zh'?'修改密码':''}}</h3>
        <div class="text-center">
            <div class="row" style="margin-bottom: 4%;">
                <div class="col-md-2 col-xs-12"></div>
                <div class="col-md-7 col-xs-12">
                    <div class="row">
                        <div class="col-md-4 col-xs-12 text-center" style="margin-top: 8px;">
                            <label class="control-label" i18n>{{language=='en'?'old password':''}}{{language=='zh'?'旧密码':''}}:</label>
                        </div>
                        <div class="col-md-8 col-xs-6">
                            <input class="form-control my_input" type="password" name="oldpass" [(ngModel)]="passwordModel.oldpass" #oldpass="ngModel" minlength="8" placeholder="{{language=='en'?'Please enter your old password':''}}{{language=='zh'?'请输入您的旧密码':''}}" i18n-placeholder required="required"/>
                            <div class="alert alert-danger" *ngIf="oldpass.invalid && (oldpass.dirty || oldpass.touched)">
                                <div *ngIf="oldpass.errors.required" i18n>
                                    {{language=='en'?'Oldpsaaword is required!':''}}{{language=='zh'?'旧密码不能为空':''}}
                                </div>
                                <div *ngIf="oldpass.errors.minlength" i18n>
                                    {{language=='en'?'Password must be at least 8 characters long.':''}}{{language=='zh'?'密码不能少于8位':''}} 
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-xs-12" style="margin-top: 8px;"><a href="javascript:;" (click)="openModal(template)" i18n>{{language=='en'?'Forget Password?':''}}{{language=='zh'?'忘记密码？':''}}</a></div>
                
                <ng-template #template>
                    <div class="modal-header">
                      <h4 class="modal-title pull-left" i18n>{{language=='en'?'Forget Password':''}}{{language=='zh'?'忘记密码？':''}}</h4>
                      <button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()">
                        <span aria-hidden="true">&times;</span>
                      </button>
                    </div>
                    <div class="modal-body">
                        <div class="text-center">
                            <div class="row" style="margin-bottom: 4%;">
                                <div class="col-md-1 col-xs-12"></div>
                                <div class="col-md-10 col-xs-12">
                                    <div class="row">
                                        <div class="col-md-5 col-xs-12" style="margin-top: 8px;">
                                            <label class="control-label" i18n>{{language=='en'?'email:':''}}{{language=='zh'?'邮箱:':''}}</label>
                                        </div>
                                        <div class="col-md-7 col-xs-6">
                                            <input class="form-control my_input" type="text" name="myEmail" [(ngModel)]="user.email" #myEmail="ngModel" email='' placeholder="{{language=='en'?'Please enter your email':''}}{{language=='zh'?'请输入您的邮箱':''}}" i18n-placeholder required="required"/>
                                            <div class="alert alert-danger" *ngIf="myEmail.invalid && (myEmail.dirty || myEmail.touched)">
                                                <div *ngIf="myEmail.errors.required" i18n>
                                                    {{language=='en'?'Email is required!':''}}{{language=='zh'?'邮箱不能为空':''}}
                                                </div>
                                                <div *ngIf="!myEmail.errors.required && myEmail.errors.email" i18n>
                                                    {{language=='en'?'Invalid email!':''}}{{language=='zh'?'邮箱格式不正确':''}} 
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-1 col-xs-12"></div>
                            </div>
                            <div class="row">
                                <div class="col-md-1 col-xs-12"></div>
                                <div class="col-md-10 col-xs-12">
                                    <div class="row mt-50">
                                        <div class="col-md-12 col-xs-12">
                                            <button class="btn btn-primary btn-block" (click)="forgetPassword(user.email)" [disabled]="myEmail.invalid || canGetemail" >{{getEmailName}}</button>
                                        </div>
                                    </div>
                                </div>
                            <div class="col-md-1 col-xs-12"></div>
                            </div>
                            
                        </div>
                    </div>
                  </ng-template>
            </div>
            <div class="row" style="margin-bottom: 4%;">
                <div class="col-md-2 col-xs-12"></div>
                <div class="col-md-7 col-xs-12">
                    <div class="row">
                        <div class="col-md-4 col-xs-12 text-center" style="margin-top: 8px;">
                            <label i18n>{{language=='en'?'new password':''}}{{language=='zh'?'新密码':''}}:</label>
                        </div>
                        <div class="col-md-8 col-xs-12">
                            <input class="form-control my_input" type="password" name="newpass" [(ngModel)]="passwordModel.newpass" #newpass="ngModel" (blur)="isSame()" minlength="8" placeholder="{{language=='en'?'please enter your password that you want to set':''}}{{language=='zh'?'请输入您的新密码':''}}" i18n-placeholder required="required"/>
                            <div class="alert alert-danger" *ngIf="newpass.invalid && (newpass.dirty || newpass.touched)">
                                <div *ngIf="newpass.errors.required" i18n>
                                    {{language=='en'?'Newpassword is required!':''}}{{language=='zh'?'新密码不能为空':''}}
                                </div>
                                <div *ngIf="newpass.errors.minlength" i18n>
                                    {{language=='en'?'Password must be at least 8 characters long.':''}}{{language=='zh'?'密码长度不能少于8位':''}}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-xs-12"></div>
            </div>
            <div class="row">
                <div class="col-md-2 col-xs-12"></div>
                <div class="col-md-7 col-xs-12">
                    <div class="row">
                        <div class="col-md-4 col-xs-12 text-center" style="margin-top: 8px;">
                            <label class="control-label" i18n>{{language=='en'?'repeat password':''}}{{language=='zh'?'重复密码':''}}:</label>
                        </div>
                        <div class="col-md-8 col-xs-12">
                            <input class="my_input form-control" type="password" name="repass" [(ngModel)]="passwordModel.repass" #repass="ngModel" (blur)="isSame()" minlength="8" placeholder="{{language=='en'?'Please enter your password again':''}}{{language=='zh'?'请再次输入密码':''}}" i18n-placeholder required="required"/>
                            <div class="alert alert-danger" *ngIf="repass.invalid && (repass.touched || repass.dirty)">
                                <div *ngIf="repass.errors.required" i18n>
                                    {{language=='en'?'Repasswprd is required!':''}}{{language=='zh'?'密码不能为空':''}} 
                                </div>
                                <div *ngIf="repass.errors.minlength" i18n>
                                    {{language=='en'?'Password must be at least 8 characters long.':''}}{{language=='zh'?'密码长度不小于8位':''}} 
                                </div>
                            </div>
                            <div class="alert alert-danger" *ngIf="!passValid" i18n>
                                {{language=='en'?'The two input password must be consistent!':''}}{{language=='zh'?'两次输入必须一致':''}}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-xs-12"></div>
            </div>
            <div class="row">
                <div class="col-md-2 col-xs-12"></div>
                <div class="col-md-7 col-xs-12">
                    <div class="row mt-50">
                        <div class="col-md-12 col-xs-12">
                            <button class="btn btn-block btn-primary" (click)="submitPass()" [disabled]="passwordModel.oldpass=='' || passwordModel.newpass=='' || passwordModel.newpass != passwordModel.repass">{{language=='en'?'Submit':''}}{{language=='zh'?'提交':''}}</button>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-xs-12"></div>
            </div>
        </div>
    </div>

</div>

